<?php

namespace app\model;
use app\utils\NumText;
use think\model\concern\SoftDelete;
class ArticleCategory extends BaseModel
{
    use SoftDelete;
    // 设置表名
    protected $name = 'article_category';
    protected $deleteTime = 'delete_at';
    // 设置主键
    protected $pk = 'id';

    // 定义与文章的关联
    public function articles()
    {
        return $this->hasMany(Article::class, 'category_id', 'id');
    }

    // 状态获取器
    public function getStatusTextAttr($value, $data)
    {
        return NumText::statusText($data['status']??'');
    }
}
